<?php

/**
 * CuerpoHumanoImagen form.
 *
 * @package    form
 * @subpackage CuerpoHumanoImagen
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $
 */
class CuerpoHumanoImagenForm extends BaseCuerpoHumanoImagenForm
{
  protected function initialize()
  {
    $this->labels = array
                    (
                      'cuerpo_humano_id' => 'Product',
                      'path'             => 'Image',
                      'main'             => 'Main',
                      'comment'          => 'Comment',                    
                    );  
  }
  
  public function configure()
  {
    $this->setWidgets(array
  	(
  	  'id'         => new sfWidgetFormInputHidden(),
  	  'path'       => new sfWidgetFormInputFileEditable
                      (
                        array
                        (
                          'file_src'    => sprintf('%s/%s', sfConfig::get('app_cuerpo_humano_images_path'), $this->object->getThumbnailPath(180)),
                          'is_image'    => true,
                          'with_delete' => false,
                          'template'    => $this->object->isNew()
                                           ? '%input%<br />%delete% %delete_label%'
                                           : sprintf
                                             (
                                               $this->object->existsThumbnail(50)
                                               ? '%%input%%<br />%%delete%% %%delete_label%%<br /><a href="%s" target="_blank">%%file%%</a>'
                                               : '%%input%%<br />%%delete%% %%delete_label%%',
                                               sprintf('%s/%s', sfConfig::get('app_cuerpo_humano_images_path'), $this->object->getThumbnailPath(180))
                                             )
                        ),
                        array
                        (
                          'size'         => 65,
                          'onKeyDown'    => 'return false;',
                          'onKeyPress'   => 'return false;'
                        )
                      ),
  	  'main'       => new sfWidgetFormSelect(array('choices' => $this->getTable()->getMain())),
    ));
    
    $this->addValidators(array
  	(
  	  'path'       => new sfValidatorFile
                      (
                        array
                        (
                          'required'   => true,
                          'max_size'   => 512000,
                          'mime_types' => 'web_images',
                          'path'       => sfConfig::get('app_cuerpo_humano_images_dir').'/'
                        )
                      ),
  	));
  	
  	$this->types = array
  	(
  	  'id'               => '=',
  	  'cuerpo_humano_id' => '-',
  	  'path'             => 'file',
  	  'main'             => array('combo', array('choices' => array_keys($this->getTable()->getMain()))),
  	  'size'             => '-',
  	  'width'            => '-',
  	  'height'           => '-',
  	  'height'           => '-',
  	  'full_mime'        => '-',
  	  'sha1'             => '-',
  	  'slug'             => '-',
  	  'created_at'       => '-',
  	  'updated_at'       => '-',
  	);
  	
    $this->validatorSchema->setPostValidator
  	(
  	  new sfValidatorPass() 
  	);
  }
}